const path = require('path');
const MiniCSSExtractPlugin = require('mini-css-extract-plugin'); // 引入提取CSS插件

module.exports = {
    entry: path.join(__dirname, 'index.styl'),
    output: {
        path: path.join(__dirname, 'dist')
    },
    mode: 'production',
    module: {
        rules: [{
            test: /(\.styl)$/,
            // 这里要注意px2rem-loader插入的顺序
            use: [MiniCSSExtractPlugin.loader, 'css-loader', {
                loader: 'px2rem-loader',
                options: {
                    remUnit: 75,
                    remPrecesion: 5
                }
            }, 'stylus-loader', ]
        }]
    },
    plugins: [
        new MiniCSSExtractPlugin({
            filename: '[name].css'
        })
    ]
};